package priv.yiyuan.example.design.facade;

/**
 * 邮件通知
 * <p>
 * 观察者模式-具体观察者
 *
 * @author YiYuan
 * @data 2025/9/13
 * @apoNote
 */
public class EmailNotificationObserver implements CustomerObserver {

    private EmailService emailService;

    public EmailNotificationObserver(EmailService emailService) {
        this.emailService = emailService;
    }

    @Override
    public void update(Customer customer) {

        if ("VIP".equals(customer.getLevel())) {
            String subject = "恭喜您升级为VIP会员！";
            String body = "亲爱的 " + customer.getName() + ", 恭喜您已成功升级为VIP会员, 享受更多专属权益！";
            emailService.sendEmail(customer.getEmail(), subject, body);
        }
    }
}
